<template>
  <div>
      <el-table :data="logData">
          <el-table-column property="name" label="操作人" width="120"></el-table-column>
          <el-table-column property="date" label="操作日期" width="280"></el-table-column>
          <el-table-column property="number" label="操作编号" width="200"></el-table-column>
          <el-table-column property="operationContent" label="操作内容"></el-table-column>
      </el-table>
      <div class="page-wrap" v-if="page">
          <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination>
      </div>
      <h2>{{assetsId}}</h2>
  </div>
</template>

<script>
export default {
  name: "HardwareDetail",
  data() {
    return {
      logData: [],
      page:false
    };
  },
  props: ["assetsId"],
  mounted() {
    console.warn("获取设备ID:" + this.assetsId);
    this.getLogData();
  },
  methods: {
    getLogData() {
      //获取用户信息渲染到页面
      let assetsId = this.assetsId;
      console.warn("页面更新 刷新数据" + assetsId);
      this.$axios({
        method: "GET",
        url: this.$api.oneAssetsLog, //链接参数增加:  "assetsId?=" + assetsId
        headers: {
          "Content-Type": "application/json"
        }
      })
        .then(res => {
          console.log("执行1");
          if (res.data.code === "000000") {
            console.log(res.data.data);
            this.page = true;
            this.logData = res.data.data.logsList;
          } else {
            this.$message({
              message: "获取信息失败",
              duration: "1000",
              type: "error",
              center: true
            });
          }
        })
        .catch(error => {
          console.error(error);
        });
    }
  }
};
</script>